home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Util / Workbench / ToolManager21s.lha / ToolManager / Programmers / examples / example.c < prev    next >
C/C++ Source or Header  |  1993-05-16  |  12KB  |  302 lines

  1. /*
  2.  * example.c  V2.1
  3.  *
  4.  * Shows the usage of the library in programs
  5.  *
  6.  * (c) 1990-1993 Stefan Becker
  7.  */
  8.  
  9. #include <utility/tagitem.h>
  10. #include <utility/hooks.h>
  11. #include <clib/dos_protos.h>
  12. #include <clib/exec_protos.h>
  13. #include <clib/intuition_protos.h>
  14. #include <clib/toolmanager_protos.h>
  15. #include <pragmas/dos_pragmas.h>
  16. #include <pragmas/exec_pragmas.h>
  17. #include <pragmas/intuition_pragmas.h>
  18. #include <pragmas/toolmanager_pragmas.h>
  19. #include <stdlib.h>
  20. #include <stdio.h>
  21.  
  22. extern struct Library *DOSBase;
  23. extern struct Library *IntuitionBase;
  24. extern struct Library *SysBase;
  25. extern struct Library *ToolManagerBase;
  26.  
  27. /* Example hook function (not used) */
  28. __geta4 BOOL hookfunc(__A0 struct Hook *hook, __A1 struct AppMessage *msg,
  29.                       __A2 void *object)
  30. {
  31.  DisplayBeep(NULL);
  32.  Delay(25);
  33.  return(TRUE);
  34. }
  35.  
  36. struct Hook hook={NULL,NULL,(ULONG (*)()) hookfunc,NULL,(APTR) 1};
  37.  
  38. struct TagItem execti1[]={
  39.                      TMOP_Arguments,  TRUE,
  40.                      TMOP_Command,    (ULONG) "'call [] getfile()'",
  41.                      TMOP_CurrentDir, (ULONG) "SYS:",
  42.                      TMOP_Delay,      0,
  43.                      TMOP_ExecType,   TMET_ARexx,
  44.                      TMOP_HotKey,     (ULONG) "ralt a",
  45.                      TMOP_PubScreen,  (ULONG) "TERM",
  46.                      TMOP_ToFront,    TRUE,
  47.                      TAG_DONE};
  48.  
  49. struct TagItem execti2[]={
  50.                      TMOP_Arguments,  TRUE,
  51.                      TMOP_Command,    (ULONG) "dir [] all",
  52.                      TMOP_CurrentDir, (ULONG) "SYS:",
  53.                      TMOP_Delay,      0,
  54.                      TMOP_ExecType,   TMET_CLI,
  55.                      TMOP_HotKey,     (ULONG) "ralt b",
  56.                      TMOP_Output,     (ULONG) "CNN:WAIT",
  57.                      TMOP_Path,       (ULONG) "C:,BOOT:,s:",
  58.                      TMOP_Priority,   10,
  59.                      TMOP_PubScreen,  (ULONG) "TERM",
  60.                      TMOP_Stack,      10000,
  61.                      TMOP_ToFront,    TRUE,
  62.                      TAG_DONE};
  63.  
  64. struct TagItem execti3[]={
  65.                      TMOP_Arguments,  TRUE,
  66.                      TMOP_Command,    (ULONG) "sys:bin/DME",
  67.                      TMOP_CurrentDir, (ULONG) "SYS:",
  68.                      TMOP_Delay,      0,
  69.                      TMOP_ExecType,   TMET_WB,
  70.                      TMOP_HotKey,     (ULONG) "ralt c",
  71.                      TMOP_Priority,   10,
  72.                      TMOP_PubScreen,  (ULONG) "TERM",
  73.                      TMOP_Stack,      10000,
  74.                      TMOP_ToFront,    TRUE,
  75.                      TAG_DONE};
  76.  
  77. struct TagItem imageti1[]={
  78.                            TMOP_File, (ULONG) "TM:Icons/Bin",
  79.                            TMOP_Data, NULL,
  80.                            TAG_DONE};
  81.  
  82. struct TagItem imageti2[]={
  83.                            TMOP_File, (ULONG) "TM:Icons/Disk",
  84.                            TMOP_Data, NULL,
  85.                            TAG_DONE};
  86.  
  87. struct TagItem imageti3[]={
  88.                            TMOP_File, (ULONG) "TM:icons/MapleV.brush",
  89.                            TMOP_Data, NULL,
  90.                            TAG_DONE};
  91.  
  92. struct TagItem imageti4[]={
  93.                            TMOP_File, (ULONG) "TM:Anims/test1.anim",
  94.                            TMOP_Data, NULL,
  95.                            TAG_DONE};
  96.  
  97. struct TagItem soundti1[]={
  98.                            TMOP_Command, (ULONG) "id warn_general",
  99.                            TAG_DONE};
  100.  
  101. struct TagItem soundti2[]={
  102.                            TMOP_Command, (ULONG) "playmod qdh2:delitracker/modules/markII/MkII.Hard.pp",
  103.                            TMOP_Port,    (ULONG) "rexx_DT",
  104.                            TAG_DONE};
  105.  
  106. struct TagItem menuti1[]={
  107.                           TMOP_Exec,  (ULONG) "testexec1",
  108.                           TMOP_Sound, (ULONG) "testsound1",
  109.                           TAG_DONE};
  110.  
  111. struct TagItem menuti2[]={
  112.                           TMOP_Exec,  (ULONG) "testexec2",
  113.                           TMOP_Sound, (ULONG) "testsound2",
  114.                           TAG_DONE};
  115.  
  116. struct TagItem menuti3[]={
  117.                           TMOP_Exec,  (ULONG) "testexec3",
  118.                           TMOP_Sound, (ULONG) "testsound1",
  119.                           TAG_DONE};
  120.  
  121. struct TagItem iconti1[]={
  122.                           TMOP_Exec,     (ULONG) "testexec1",
  123.                           TMOP_LeftEdge, 100,
  124.                           TMOP_Image,    (ULONG) "testimage1",
  125.                           TMOP_ShowName, TRUE,
  126.                           TMOP_Sound,    (ULONG) "testsound1",
  127.                           TMOP_TopEdge,  350,
  128.                           TAG_DONE};
  129.  
  130. struct TagItem iconti2[]={
  131.                            TMOP_Exec,     (ULONG) "testexec2",
  132.                            TMOP_LeftEdge, 170,
  133.                            TMOP_Image,    (ULONG) "testimage2",
  134.                            TMOP_ShowName, FALSE,
  135.                            TMOP_Sound,    (ULONG) "testsound2",
  136.                            TMOP_TopEdge,  350,
  137.                            TAG_DONE};
  138.  
  139. struct TagItem iconti3[]={
  140.                           TMOP_Exec,     (ULONG) "testexec3",
  141.                           TMOP_LeftEdge, 240,
  142.                           TMOP_Image,    (ULONG) "testimage3",
  143.                           TMOP_ShowName, TRUE,
  144.                           TMOP_Sound,    (ULONG) "testsound1",
  145.                           TMOP_TopEdge,  350,
  146.                           TAG_DONE};
  147.  
  148. struct TagItem iconti4[]={
  149.                           TMOP_Exec,     (ULONG) "testexec1",
  150.                           TMOP_LeftEdge, 330,
  151.                           TMOP_Image,    (ULONG) "testimage4",
  152.                           TMOP_ShowName, FALSE,
  153.                           TMOP_Sound,    (ULONG) "testsound2",
  154.                           TMOP_TopEdge,  350,
  155.                           TAG_DONE};
  156.  
  157. char *tool1[]={"testexec1","testimage1","testsound1"};
  158. char *tool2[]={"testexec2","testimage2","testsound2"};
  159. char *tool3[]={"testexec3","testimage3","testsound1"};
  160. char *tool4[]={"testexec1","testimage4","testsound2"};
  161. struct TagItem dockti1[]={
  162.                          TMOP_LeftEdge,  80,
  163.                          TMOP_TopEdge,   200,
  164.                          TMOP_Activated, TRUE,
  165.                          TMOP_Centered,  FALSE,
  166.                          TMOP_Columns,   3,
  167.                          TMOP_FrontMost, TRUE,
  168.                          TMOP_HotKey,    (ULONG) "rcommand rshift d",
  169.                          TMOP_Vertical,  TRUE,
  170.                          TMOP_Text,      FALSE,
  171.                          TMOP_Title,     (ULONG) "Blaaaa 1",
  172.                          TMOP_Pattern,   TRUE,
  173.                          TMOP_Tool,      (ULONG) tool1,
  174.                          TMOP_Tool,      (ULONG) tool2,
  175.                          TMOP_Tool,      (ULONG) tool3,
  176.                          TMOP_Tool,      (ULONG) tool4,
  177.                          TAG_DONE};
  178.  
  179. struct TextAttr ta={"topaz.font",20,0,0};
  180.  
  181. struct TagItem dockti2[]={
  182.                          TMOP_LeftEdge,  80,
  183.                          TMOP_TopEdge,   300,
  184.                          TMOP_Activated, TRUE,
  185.                          TMOP_Centered,  TRUE,
  186.                          TMOP_Columns,   2,
  187.                          TMOP_FrontMost, TRUE,
  188.                          TMOP_HotKey,    (ULONG) "rcommand rshift e",
  189.                          TMOP_Vertical,  TRUE,
  190.                          TMOP_Text,      TRUE,
  191.                          TMOP_Title,     (ULONG) "Blaaaa 2",
  192.                          TMOP_Tool,      (ULONG) tool1,
  193.                          TMOP_Tool,      (ULONG) tool2,
  194.                          TMOP_Tool,      (ULONG) tool3,
  195.                          TMOP_Tool,      (ULONG) tool4,
  196.                          TMOP_Menu,      TRUE,
  197.                          TMOP_Font,      (ULONG) &ta,
  198.                          TAG_DONE};
  199.  
  200. struct TagItem dockti3[]={
  201.                          TMOP_LeftEdge,  300,
  202.                          TMOP_TopEdge,   200,
  203.                          TMOP_Activated, TRUE,
  204.                          TMOP_Centered,  FALSE,
  205.                          TMOP_Columns,   2,
  206.                          TMOP_FrontMost, TRUE,
  207.                          TMOP_HotKey,    (ULONG) "rcommand rshift f",
  208.                          TMOP_Vertical,  FALSE,
  209.                          TMOP_Text,      FALSE,
  210.                          TMOP_Tool,      (ULONG) tool1,
  211.                          TMOP_Tool,      (ULONG) tool2,
  212.                          TMOP_Tool,      (ULONG) tool3,
  213.                          TMOP_Tool,      (ULONG) tool4,
  214.                          TAG_DONE};
  215.  
  216. struct TagItem dockti4[]={
  217.                          TMOP_LeftEdge,  300,
  218.                          TMOP_TopEdge,   300,
  219.                          TMOP_Activated, TRUE,
  220.                          TMOP_Centered,  TRUE,
  221.                          TMOP_Columns,   2,
  222.                          TMOP_FrontMost, TRUE,
  223.                          TMOP_HotKey,    (ULONG) "rcommand rshift g",
  224.                          TMOP_Vertical,  FALSE,
  225.                          TMOP_Text,      TRUE,
  226.                          TMOP_Tool,      (ULONG) tool1,
  227.                          TMOP_Tool,      (ULONG) tool2,
  228.                          TMOP_Tool,      (ULONG) tool3,
  229.                          TMOP_Tool,      (ULONG) tool4,
  230.                          TAG_DONE};
  231.  
  232. struct TagItem dockti5[]={
  233.                          TMOP_LeftEdge,  450,
  234.                          TMOP_TopEdge,   200,
  235.                          TMOP_Activated, TRUE,
  236.                          TMOP_Centered,  FALSE,
  237.                          TMOP_PopUp,     TRUE,
  238.                          TMOP_Columns,   2,
  239.                          TMOP_FrontMost, TRUE,
  240.                          TMOP_HotKey,    (ULONG) "rcommand rshift h",
  241.                          TMOP_Vertical,  TRUE,
  242.                          TMOP_Text,      FALSE,
  243.                          TMOP_Tool,      (ULONG) tool1,
  244.                          TMOP_Tool,      (ULONG) tool2,
  245.                          TMOP_Tool,      (ULONG) tool3,
  246.                          TMOP_Tool,      (ULONG) tool4,
  247.                          TAG_DONE};
  248.  
  249. struct TagItem dockti6[]={
  250.                          TMOP_LeftEdge,  450,
  251.                          TMOP_TopEdge,   300,
  252.                          TMOP_Activated, TRUE,
  253.                          TMOP_Centered,  TRUE,
  254.                          TMOP_PopUp,     TRUE,
  255.                          TMOP_Columns,   2,
  256.                          TMOP_FrontMost, TRUE,
  257.                          TMOP_HotKey,    (ULONG) "rcommand rshift i",
  258.                          TMOP_Vertical,  TRUE,
  259.                          TMOP_Text,      TRUE,
  260.                          TMOP_Tool,      (ULONG) tool1,
  261.                          TMOP_Tool,      (ULONG) tool2,
  262.                          TMOP_Tool,      (ULONG) tool3,
  263.                          TMOP_Tool,      (ULONG) tool4,
  264.                          TAG_DONE};
  265.  
  266. int main(int argc, char *argv[])
  267. {
  268.  void *handle;
  269.  
  270.  if (handle=AllocTMHandle()) {
  271.   printf("handle: 0x%08lx\n",handle);
  272.  
  273.   CreateTMObjectTagList(handle,"testexec1",TMOBJTYPE_EXEC,execti1);
  274.   CreateTMObjectTagList(handle,"testexec2",TMOBJTYPE_EXEC,execti2);
  275.   CreateTMObjectTagList(handle,"testexec3",TMOBJTYPE_EXEC,execti3);
  276.   CreateTMObjectTagList(handle,"testimage1",TMOBJTYPE_IMAGE,imageti1);
  277.   CreateTMObjectTagList(handle,"testimage2",TMOBJTYPE_IMAGE,imageti2);
  278.   CreateTMObjectTagList(handle,"testimage3",TMOBJTYPE_IMAGE,imageti3);
  279.   CreateTMObjectTagList(handle,"testimage4",TMOBJTYPE_IMAGE,imageti4);
  280.   CreateTMObjectTagList(handle,"testsound1",TMOBJTYPE_SOUND,soundti1);
  281.   CreateTMObjectTagList(handle,"testsound2",TMOBJTYPE_SOUND,soundti2);
  282.   CreateTMObjectTagList(handle,"testmenu1",TMOBJTYPE_MENU,menuti1);
  283.   CreateTMObjectTagList(handle,"testmenu2",TMOBJTYPE_MENU,menuti2);
  284.   CreateTMObjectTagList(handle,"testmenu3",TMOBJTYPE_MENU,menuti3);
  285.   CreateTMObjectTagList(handle,"testicon1",TMOBJTYPE_ICON,iconti1);
  286.   CreateTMObjectTagList(handle,"testicon2",TMOBJTYPE_ICON,iconti2);
  287.   CreateTMObjectTagList(handle,"testicon3",TMOBJTYPE_ICON,iconti3);
  288.   CreateTMObjectTagList(handle,"testicon4",TMOBJTYPE_ICON,iconti4);
  289.   CreateTMObjectTagList(handle,"testdock1",TMOBJTYPE_DOCK,dockti1);
  290.   CreateTMObjectTagList(handle,"testdock2",TMOBJTYPE_DOCK,dockti2);
  291.   CreateTMObjectTagList(handle,"testdock3",TMOBJTYPE_DOCK,dockti3);
  292.   CreateTMObjectTagList(handle,"testdock4",TMOBJTYPE_DOCK,dockti4);
  293.   CreateTMObjectTagList(handle,"testdock5",TMOBJTYPE_DOCK,dockti5);
  294.   CreateTMObjectTagList(handle,"testdock6",TMOBJTYPE_DOCK,dockti6);
  295.  
  296.   Wait(0xF000);
  297.  
  298.   FreeTMHandle(handle);
  299.  }
  300.  exit(0);
  301. }
  302.